home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 3 / Info_Mac_1994-01.iso / Development / Source / MultiSession 1.04 Source / Core 27⁄June⁄1993 / CYesNoBox.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-04  |  2.6 KB  |  121 lines  |  [TEXT/KAHL]

  1. /* CYesNoBox.c */
  2.  
  3. #include "CYesNoBox.h"
  4. #include "CImagePane.h"
  5. #include "CStaticText.h"
  6. #include "Memory.h"
  7. #include "StringUtils.h"
  8.  
  9. #define YesButtonLoc (131L*65536L + 1)
  10. #define NoButtonLoc (131L*65536L + 2)
  11. #define TextBoxLoc (131L*65536L + 3)
  12. #define WindowLoc (131L*65536L + 4)
  13.  
  14. #define KillButtonLocID (0x00810003)
  15. #define ErrorPictID (136)
  16. #define PictLocID (0x00820000) /* add PICT ID to find local index */
  17.  
  18.  
  19. void                CYesButton::IYesButton(CWindow* TheModalDialog, MyBoolean* Result,
  20.                             Handle Text)
  21.     {
  22.         LongPoint        Start;
  23.         LongPoint        Extent;
  24.  
  25.         AnswerLoc = Result;
  26.         GetRect(YesButtonLoc,&Start,&Extent);
  27.         ISimpleButton(Start,Extent,Text,13,0,TheModalDialog,TheModalDialog);
  28.     }
  29.  
  30.  
  31. MyBoolean        CYesButton::DoThang(void)
  32.     {
  33.         *AnswerLoc = True;
  34.         delete Window;
  35.         return True;
  36.     }
  37.  
  38.  
  39. /****************/
  40.  
  41.  
  42. void                CNoButton::INoButton(CWindow* TheModalDialog, MyBoolean* Result,
  43.                             Handle Text)
  44.     {
  45.         LongPoint        Start;
  46.         LongPoint        Extent;
  47.  
  48.         AnswerLoc = Result;
  49.         GetRect(NoButtonLoc,&Start,&Extent);
  50.         ISimpleButton(Start,Extent,Text,'.',cmdKey,TheModalDialog,TheModalDialog);
  51.     }
  52.  
  53.  
  54. MyBoolean        CNoButton::DoThang(void)
  55.     {
  56.         *AnswerLoc = False;
  57.         delete Window;
  58.         return True;
  59.     }
  60.  
  61.  
  62. /****************/
  63.  
  64.  
  65. MyBoolean        CYesNoBox::ShouldIDoIt(long MessageID, Handle ExtraText, long YesTextID,
  66.                             long NoTextID)
  67.     {
  68.         CImagePane*            Icon;
  69.         CStaticText*        StaticText;
  70.         CYesButton*            YesButton;
  71.         CNoButton*            NoButton;
  72.         LongPoint                Start;
  73.         LongPoint                Extent;
  74.         Handle                    MessageText;
  75.         Handle                    AccumulatedText;
  76.  
  77.         MyBoolean                Result;
  78.  
  79.  
  80.         GetRect(WindowLoc,&Start,&Extent);
  81.         Start = CenterRect(Extent,LongPointOf(screenBits.bounds.right
  82.             - screenBits.bounds.left,screenBits.bounds.bottom - screenBits.bounds.top));
  83.         IModalDialog(Start,Extent,DontAllowMenus);
  84.  
  85.         YesButton = new CYesButton;
  86.         YesButton->IYesButton(this,&Result,GetCString(YesTextID));
  87.  
  88.         NoButton = new CNoButton;
  89.         NoButton->INoButton(this,&Result,GetCString(NoTextID));
  90.  
  91.         if (MessageID != 0)
  92.             {
  93.                 MessageText = GetCString(MessageID);
  94.             }
  95.          else
  96.             {
  97.                 MessageText = AllocHandle(0);
  98.             }
  99.         if (ExtraText == NIL)
  100.             {
  101.                 ExtraText = AllocHandle(0);
  102.             }
  103.  
  104.         BeginStringOperation();
  105.         RegisterString(MessageText);
  106.         RegisterString(ExtraText);
  107.         AccumulatedText = ReplaceStr(MessageText,CString("_"),ExtraText);
  108.         EndStringOperation(AccumulatedText);
  109.  
  110.         GetRect(TextBoxLoc,&Start,&Extent);
  111.         StaticText = new CStaticText;
  112.         StaticText->IStaticText(Start,Extent,AccumulatedText,0,12,this,this,JustifyLeft);
  113.  
  114.         GetRect(PictLocID + ErrorPictID,&Start,&Extent);
  115.         Icon = new CImagePane;
  116.         Icon->IImagePane(Start,Extent,this,this,ErrorPictID);
  117.  
  118.         DoEventLoop();
  119.         return Result;
  120.     }
  121.